$(function () {

    $("#jqGrid").jqGrid({
        url: ctx+'/sys/role/list',
        datatype: "json",
        colModel: [			
			{ label: '角色ID', name: 'roleId', index: "role_id", width: 45, key: true },
			{ label: '角色名称', name: 'roleName', index: "role_name", width: 75 },
			{ label: '备注', name: 'remark', width: 100 },
			{ label: '创建时间', name: 'createTime', index: "create_time", width: 80}
        ],
		viewrecords: true,
        rowNum: 10,
		rowList : [10,30,50],
        rownumbers: true, 
        rownumWidth: 25, 
        autowidth:true,
        multiselect: true,
//        toolbar : [ true, "top" ],
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.pageNum",
            total: "page.pages",
            records: "page.total"
        },
        prmNames : {
        	  page:"page", 
              rows:"limit", 
              order: "order"
        },
        gridComplete:function(){
        	//隐藏grid底部滚动条
        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
        }
    });
    jQuery("#jqGrid").jqGrid('navGrid', '#jqGridPager', {
        edit : false,
        add : false,
        del : false
      });
    
    $("#btnAdd").click(function (){
    	showDefinedWindow(ctx+'/sys/role/roleOper','add',1000,700);
    });
    
    $("#queryBut").click(function (){
    	var params=$("#queryForm").serializeObject();
    	reloadGrid("jqGrid",params);
    });
    
    $("#btnUpdate").click(function (){
    	var row=getSelectedRow("jqGrid");
    	showDefinedWindow(ctx+'/sys/role/roleOper?roleId='+row.roleId,'add',1000,700);
    });
    
    

});





